<%--
  Created by IntelliJ IDEA.
  User: 28101
  Date: 2021/9/23
  Time: 11:56
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link href="/css/bootstrap-theme.css" rel="stylesheet">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <script src="../js/jquery-3.3.1.min.js"></script>
    <title>结算</title>
    <style>
        .tabdiv{
            width: 70%;
            margin-left: 200px;
            margin-top: 50px;
        }

        .textdiv{
            font-size: 30px;
            color: rgba(255, 119, 0, 0.93);
            margin-bottom: 30px;
        }

        .peisongtext{
            font-size: 30px;
            margin-top: 50px;
            margin-bottom: 20px;
        }

        .addrdiv{
            font-size: 20px;
            margin-top: 10px;
            border:1px solid #000;
        }

        .sumshop{
            font-size: 30px;
            color: rgba(255, 102, 0, 0.89);
        }

        .queren{
            width: 250px;
            height: 50px;
            background-color: rgba(255, 102, 0, 0.89);
            font-size: 18px;
            color: white;
            border: none;
            margin-top: 20px;
        }

    </style>

</head>
<body>

    <div style="height: 50px;background-color: rgba(250, 235, 215, 0.57)">
        <table style="position:relative; left:260px; top:15px;margin-left: 500px">
            <tr>
                <td width="60px" align="center" class="loginbtn">主页</td>
                <td width="200px"></td>
                <td width="200px" align="center" class="shopcartbtn">购物车</td>

                <td width="200px" align="center" class="mycartbtn">我的订单</td>

                <jstl:if test="${user != null}">
                    <div hidden="hidden">${user.uid }</div>
                    <td width="300px" align="center" hidden="hidden">
                            ${user.uid }
                    </td>
                    <td>
                            ${user.name }
                    </td>
                </jstl:if>

                <jstl:if test="${user == null}">
                    <td class="login">
                        登录
                    </td>
                </jstl:if>
            </tr>
        </table>
    </div>

    <div style="margin-top: 10px;padding: 20px" class="tabdiv">
        <div class="textdiv">订单结算</div>
        <table class="table table-striped table-hover table-bordered">
            <tr>
                <th>商品图片</th>
                <th>商品</th>
                <th>商品版本</th>
                <th>商品颜色</th>
                <th>商品数量</th>
                <th>商品总价</th>
            </tr>

            <jstl:if test="${cdmap != null}">

                <jstl:forEach items="${cdmap }" var="map">
                    <tr>
                        <td>
                            <img src="/imgs/${map.value.commodityImgs[0].src }" width="100px" height="120px" />
                        </td>
                        <td>${map.value.commodityName}</td>
                        <td>
                            ${map.value.commodityVersion[0].versionname }
                        </td>
                        <td>
                            ${map.value.commodityColors[0].colorname }
                        </td>
                        <td>
                           ${map.key.count }
                        </td>
                        <td>
                            ${map.value.commodityVersion[0].cprice * map.key.count }
                        </td>
                    </tr>
                </jstl:forEach>
            </jstl:if>

        </table>

        <div>
            <div class="peisongtext">配送地址:</div>
            <div class="addrdiv">
                ${user.addressList[0].address }
                ${user.addressList[0].tel }
            </div>
        </div>

        <div style="float: right;margin-right: 20px;margin-top: 50px">
            <div class="sumshop">总计：${sumshop } 元</div>

            <button class="queren">确认</button>
        </div>

    </div>

    <script src="/js/bootstrap.min.js"></script>

    <script>

        $(".queren").click(function () {
            window.location.href = "/ShoppingCartServlet?method=saveShopCart";
        })

        $(".login").click(function () {
            window.location.href = "/UserServlet?method=logout";
        });

        $(".loginbtn").click(function () {
            window.location.href = "/index.jsp";
        })

        $(".shopcartbtn").click(function () {
            window.location.href = "/jsp/shoppingCustom.jsp";
        })

        $(".mycartbtn").click(function () {
            window.location.href = "/HisShoppingCustomServlet?method=getUserHisShoppingCustom";
        })

    </script>

</body>
</html>
